﻿using System.Windows;
using Microsoft.Phone.Controls;

namespace JustinAngel.MindwaveSensor.WP8.TestApp
{
    public partial class ManualConnection : PhoneApplicationPage
    {
        public ManualConnection()
        {
            InitializeComponent();
            btnConnect.IsEnabled = !Mindwave.Current.IsConnected;
            btnDisconnect.IsEnabled = Mindwave.Current.IsConnected;

            lstOutput.Items.Add(Mindwave.Current.State);
            Mindwave.Current.StateChanged += Current_StateChanged;
        }

        void Current_StateChanged(object sender, MindwaveStateChangedEventArgs e)
        {
            lstOutput.Items.Add(e.CurrentState.ToString());
            btnConnect.IsEnabled = !Mindwave.Current.IsConnected;
            btnDisconnect.IsEnabled = Mindwave.Current.IsConnected;
        }

        private void btnConnect_Click(object sender, RoutedEventArgs e)
        {
            Mindwave.Current.Start();
        }

        private void btnDisconnect_Click(object sender, RoutedEventArgs e)
        {
            Mindwave.Current.Stop();
        }
    }
}